package com.xkdx.caipiao.open;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.xkdx.caipiao.R;
import com.xkdx.caipiao.presistence.quert.OpenAwardNumQueryItemInfo;
import com.xkdx.caipiao.statics.IConstants;

public class OpenDetailActivity extends Activity {
	private ImageView back;
	private OpenAwardNumQueryItemInfo info;
	private TextView name, period, time;
	private Button ball1, ball2, ball3, ball4, ball5, ball6, ball7;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.open_detail_caipiao);
		info = (OpenAwardNumQueryItemInfo) getIntent().getSerializableExtra("openinfo");
		back = (ImageView) findViewById(R.id.open_detail_back);
		name = (TextView) findViewById(R.id.open_detail_name);
		period = (TextView) findViewById(R.id.open_detail_periods);
		time = (TextView) findViewById(R.id.open_detail_time);
		ball1 = (Button) findViewById(R.id.open_detail_ball1);
		ball2 = (Button) findViewById(R.id.open_detail_ball2);
		ball3 = (Button) findViewById(R.id.open_detail_ball3);
		ball4 = (Button) findViewById(R.id.open_detail_ball4);
		ball5 = (Button) findViewById(R.id.open_detail_ball5);
		ball6 = (Button) findViewById(R.id.open_detail_ball6);
		ball7 = (Button) findViewById(R.id.open_detail_ball7);
		back.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				finish();
			}
		});

		setValue();

	}

	private void setValue() {
		
		period.setText(info.getOpenawardtime());
		if (info.getLotteryid().equals("qxc")) {
			name.setText(IConstants.SEVEN_COLOR);
			String[] str = info.getOpennum().replace("#", ",").split(",");
			ball4.setVisibility(View.VISIBLE);
			ball5.setVisibility(View.VISIBLE);
			ball6.setVisibility(View.VISIBLE);
			ball7.setVisibility(View.VISIBLE);
			ball1.setText(str[0]);
			ball2.setText(str[1]);
			ball3.setText(str[2]);
			ball4.setText(str[3]);
			ball5.setText(str[4]);
			ball6.setText(str[5]);
			ball7.setText(str[6]);

		}
		else if (info.getLotteryid().equals("dlt")) {
			name.setText(IConstants.LOTTO);
			String[] str = info.getOpennum().replace("#", ",").split(",");
			ball4.setVisibility(View.VISIBLE);
			ball5.setVisibility(View.VISIBLE);
			ball6.setVisibility(View.VISIBLE);
			ball7.setVisibility(View.VISIBLE);
			ball6.setBackgroundResource(R.drawable.ball_blue_caipiao);
			ball7.setBackgroundResource(R.drawable.ball_blue_caipiao);
			ball1.setText(str[0]);
			ball2.setText(str[1]);
			ball3.setText(str[2]);
			ball4.setText(str[3]);
			ball5.setText(str[4]);
			ball6.setText(str[5]);
			ball7.setText(str[6]);
		} else if (info.getLotteryid().equals("pls")) {
			name.setText(IConstants.ARRANGE_3);
			String[] str = info.getOpennum().split(",");
			ball1.setText(str[0]);
			ball2.setText(str[1]);
			ball3.setText(str[2]);
		} else {
			name.setText(IConstants.ARRANGE_5);
			ball4.setVisibility(View.VISIBLE);
			ball5.setVisibility(View.VISIBLE);
			String[] str = info.getOpennum().split(",");
			ball1.setText(str[0]);
			ball2.setText(str[1]);
			ball3.setText(str[2]);
			ball4.setText(str[3]);
			ball5.setText(str[4]);

		}
	}

}
